package nig.mf.plugin.sink;

import arc.mf.plugin.ConfigurationResolver;
import arc.mf.plugin.DataSinkRegistry;
import arc.mf.plugin.PluginLog;
import arc.mf.plugin.PluginModule;
import arc.mf.plugin.PluginService;
import java.util.Collection;
import java.util.Collections;

/**
 * PluginModule for custom SCPSink.
 * 
 * @author King Lung Chiu
 */
public class SCPSinkModule implements PluginModule
{

	@Override
	public String description() {
      info("description()");
		return "SCP Sink Module";
	}

	@Override
	public void initialize(ConfigurationResolver arg0) throws Throwable {
      info("initialize()");
		DataSinkRegistry.add(this, new SCPSink());
	}

	@Override
	public Collection<PluginService> services() {
      info("services()");
//		return Arrays.asList((PluginService) new Test());
		return Collections.emptyList();
	}

	@Override
	public void shutdown(ConfigurationResolver arg0) throws Throwable {
      info("shutdown()");
		DataSinkRegistry.removeAll(this);
	}

	@Override
	public String vendor() {
      info("vendor()");
		return "VeRSI";
	}

	@Override
	public String version() {
      info("version()");
		return "0.0.1";
	}

   private void info(String msg) {
      log(PluginLog.INFORMATION, msg);
   }
   private void log(int level, String msg) {
      PluginLog.log(this.getClass().getCanonicalName()).add(level, msg);
   }
   private void log(int level, String msg, Throwable err) {
      PluginLog.log(this.getClass().getCanonicalName()).add(level, msg, err);
   }
}